<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>推广链接</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/aui.css" />
    <script src="js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="js/wxrem.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/art-template.js" type="text/javascript" charset="utf-8"></script>
    <!--<script src="//s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js"></script>-->
    <script src="js/md5.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        document.writeln("<script type=\"text/javascript\" src=\"js/common.js?"+ Math.random() + "\"></scr"+"ipt>");
    </script>

</head>
<style>
    .box{
        padding: 1.5rem 1.5rem 0;
    }
    .links_box{
        padding: 0 2rem;
        box-shadow: 0px 5px 20px #ebebeb;
        overflow: hidden;

    }
    .links_url{
        height: 7rem;
        border-bottom: 1px solid #ebebeb;
    }
    .links_url div{

        font-size: 1.6rem;
    }
    .links_url h5{
        margin-top: 2.2rem;
        font-size: 1.6rem;
        color: black;
    }
    .links_url div input{
        color:#1aad1a ;
        float: left;
        line-height: 3rem;
        font-size: 1.4rem;
        width: 18rem;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
        background: #f5f5f5;
    }
    .links_url div span{
        display: block;
        float: right;
        margin-top: -1rem;
        width: 5.5rem;
        height: 2.8rem;
        border-radius: 1.4rem;
        background: #ffd74b;
        font-size: 1.4rem;
        line-height: 2.8rem;
        color: #101010;
        text-align: center;
    }
    .links_code{
        height: 18.5rem;
    }
    .links_code h5{
        margin-top: 2.2rem;
        font-size: 1.5rem;
        color: black;
    }
    .links_code div{
        width: 11.5rem;
        height: 11.5rem;
        margin: 1.5rem auto 0;
    }
    .links_code img{
        height: 100%;
        width: 100%;
    }

</style>
<body>
<div class="box">
    <div class="links_box">
        <div class="links_url">
            <h5>方式一：链接网址</h5>
            <div><input id="text" value=""> <span onclick="copyText()">复制</span></div>
        </div>
        <div class="links_code">
            <h5>方式二：链接二维码</h5>
            <div><img src="img/midu_code.jpg" alt=""></div>
        </div>
    </div>

</div>
</body>
<script>
    //
    //推广链接


    if(authorizerAppid=='undefined'){ //分销商用户的连接生城
        var sign = hex_md5(objKeySort({token: token, timestamp: date}))
        $.ajax({
            type: "get",
            url: hostUrl + "merchant/extensionlink/unauthorized",
            data: {
                redirectURI:shareUrl+'index.html?merchantId=' + openId,
                token: token,
                timestamp: date,
                sign:sign
            },
            async: true,
            success: function (data) {
                if(data.status==0){
                    $('#text').val(data.data.shortUrl)
                }

            }
        });
        var qrcodeUrl =hostUrl + "merchant/qrcode?redirectURI=" +shareUrl+"index.html?merchantId=" + openId;
        $('.links_code img').attr('src',qrcodeUrl)

    }else {//C端用户的连接生成
        var sign = hex_md5(objKeySort({token: token, timestamp: date}))
        $.ajax({
            type: "get",
            url: hostUrl + "merchant/extensionlink/authorized",
            data: {
                redirectURI:shareUrl+'index.html?merchantId=' + openId,//这个openId 代表商户id
                token: token,
                timestamp: date,
                sign:sign
            },
            async: true,
            success: function (data) {
                if(data.status==0){
                    $('#text').val(data.data.shortUrl)

                }

            }
        });
        var qrcodeUrl =hostUrl + "merchant/qrcode?redirectURI=" +shareUrl+"index.html?merchantId=" + openId +"&token=" + token +"&timestamp="+ date +"&sign="+ sign
        $('.links_code img').attr('src',qrcodeUrl)

    }


    function copyText(){
        var ele = document.getElementById("text");//ele是要复制的元素的对象
        ele.focus();
        ele.setSelectionRange(0, ele.value.length);
        if(document.execCommand('copy', false, null)){
            alert("复制成功")
        } else{
            alert("复制失败")
        }


    }

    //禁止分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>
</html>